<template>
  <div>
    <!-- 处方状态选择 -->
  <el-form :inline="true" :model="searchForm" label-width="100px">
  </el-form>
    <div class="summary">
      截止当日，已审核 <span>{{ processedCount }}</span> 条，待审核 <span>{{ pendingCount }}</span> 条
    </div>

    <!--表格区域-->
    <el-card class="box-card">
      <el-table
        :data="unitList"
        @selection-change="handleSelectionChange"
        style="width: 100%"
        class="table-main"
      >
        <!--复选框,默认会有事件handleSelectionChange-->
        <el-table-column prop="patientName" label="患者姓名"> </el-table-column>
        <el-table-column prop="patientPhone" label="患者电话"> </el-table-column>
        <el-table-column prop="hospitalName" label="医院名称"></el-table-column>
        <el-table-column prop="departmentName" label="科室名称"> </el-table-column>
        <el-table-column prop="prescribingDoctor" label="开方医生"> </el-table-column>
        <el-table-column prop="cost" label="费用"> </el-table-column>
        <el-table-column prop="submissionTime" label="提交时间"> </el-table-column>
        <el-table-column prop="reviewerName" label="审核人"> </el-table-column>
        <el-table-column prop="examineTime" label="审核时间"> </el-table-column>
        <el-table-column prop="examineStatus" label="审核状态"> </el-table-column>
        <el-table-column prop="controls" label="操作">
          <template v-slot="scope">
            <router-link :to="{ path: '/views/index' }">
            <el-button @click="viewDatails(scope.row)" type="text" size="small">查看</el-button>
            </router-link>
          </template>
        </el-table-column>




      </el-table>
      <div style="display: flex; justify-content: flex-end;">
  <el-pagination
        background
        @current-change="handleCurrentChange"
        :current-page="pageNum"
        :page-sizes="[1, 2, 3]"
        :page-size="pageSize"
        layout=" sizes, prev, pager, next"
        :total="total"
      >
      </el-pagination>
</div>

    </el-card>
  </div>
</template>

<script>
import { getList } from "@/api/md/unit";

export default {
  name: "unit",
  data() {
    return {
      processedCount: 1008611,
      pendingCount: 15372,
      startDate: "", //开始日期
      endDate: "",  //结束日期
      unitList: [],//单位列表
      searchForm: {//模糊搜索条件
      },
      pageNum: 1,// 当前页码
      pageSize: 3,   //每页显示条数
      total: 0,
      dialogVisible: false,
    };
  },

  methods: {
    viewDetails(row) {//查看详情
      this.$router.push({
        name:'PrescriptionDetails',
        params:{ id:row.id }
      } );
    },
    viewDatails(row) {
      console.log('查看详情:', row);
    },
    // 日期范围
    handleStartDateChange(date) {
      console.log("选择的开始日期",date);
    },
    handleEndDateChange(date) {
      console.log("选择的结束日期",date);
    },
    handleCurrentChange(currentPage) {
      this.pageNum = currentPage;
      this.getUnitList();//获取单位列表
    },
    // 模糊搜索条件
    onSearch() {
      this.getUnitList();
    },
    //获取单位列表
    getUnitList() { //获取单位列表
      getList({//获取单位列表
        pageNum: this.pageNum,//当前页码
        pageSize: this.pageSize,
        prescriptionId: this.searchForm.prescriptionId,//处方id
        patientName: this.searchForm.patientName,//患者姓名
        status: this.searchForm.status,//处方状态
        department: this.searchForm.department,//科室
        startDate: this.startDate,//开始日期
        endDate: this.endDate,//结束日期
      }).then((res) => {
        // res.data取出的是pageinfo对象，里面包含了分页信息和数据list
        this.unitList = res.data.list;
        this.total = res.data.total;
      });
    },
    changePrimaryFlag(val) {
      if (val === "N") {
        //获取待审核列表
        getList({
          pageNum: 1,
          pageSize: this.total,
          primaryFlag: "Y",
          prescriptionId: this.searchForm.prescriptionId,
          patientName: this.searchForm.patientName,
        }).then((res) => {
          // res.data取出的是pageinfo对象，里面包含了分页信息和数据list
          this.primaryList = res.data.list;
        });
      }
    },
    //根据名称获取单位信息
    getUnitByName(name) {  //根据名称获取单位信息
      getUnitByName({//根据名称获取单位信息
        name: name,
      }).then((res) => {
        // res.data取出的是单位信息
        this.unitMeasure = res.data;//赋值给处方信息
      });
    },
    //选择行
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
  },
  // 这是组件创建完成后执行的函数
  created() {
    this.getUnitList();
  },
};
</script>
<style scoped>
.el-upload__text em {
  font-size: 14px;
  color: #409EFF;
}

.summary {
  background-color: rgba(239, 246, 255);
  padding: 10px;
  border: 1px solid honeydew;
  color: black;
  font-family: "微软雅黑", sans-serif; /* 设置字体 */
  font-weight: bold;  /* 设置字体粗细 */
}
.summary span {
  color: crimson;
  font-weight: bold;
}
.text {
  font-size: 14px;
}

.item {
  padding: 18px 0;
}

.box-card {
  width: 100%;
}
.table-main {
  width: 100%; /* 表格占满父容器宽度 */
  max-width: 1200px; /* 设置最大宽度，以便在大屏幕上不会过宽 */
  height: 500px;


}


</style>
